import sys
import os
import time
import Skype4Py
import random
sys.path.append("lib")
from skypybot import SkyPyBot

# ----------------------------------------------------------------------------------------------------
# Fired on attachment status change. Here used to re-attach this script to Skype in case attachment is lost. Just in
#case.
def OnAttach(status):
    print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status)
    if status == Skype4Py.apiAttachAvailable:
        skype.Attach()

    if status == Skype4Py.apiAttachSuccess:
       print('***************************************')


# ----------------------------------------------------------------------------------------------------
# Creating instance of Skype object, assigning handler functions and attaching to Skype.
bot = SkyPyBot()

skype = Skype4Py.Skype()
skype.OnAttachmentStatus = OnAttach
skype.OnMessageStatus = bot.OnMessageStatus

print('***************************************')
print 'Connecting to Skype...'
skype.Attach()

print bot.helpsk(None, None)
# ----------------------------------------------------------------------------------------------------
# Looping until user types 'exit'
Cmd = ''
while not Cmd == 'exit':
    Cmd = raw_input('')

